<template>
  <div class="wrapper">
    <van-nav-bar
  left-text="返回"
  right-text="确认"
  left-arrow
  @click-left="onCancel"
  @click-right="toHome"
/>
    <h1>请填写您乘坐的信息</h1>
    <van-row>
  <van-col span="8">列车次号</van-col>
  <van-col span="8">车厢号</van-col>
  <van-col span="8">座位号</van-col>
</van-row>
    <van-picker 
    title="选择乘坐信息" 
    :columns="columns"
    @confirm="toHome"
    @cancel="onCancel"
    ref="addressRef"
     />
  </div>
</template>
<script>
import { Dialog,Notify  } from 'vant';
export default {
data() {
return {
        columns: [ { text: 'C7055', children: [ { text: '1', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' } ],}, { text: '2', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '3', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '4', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '5', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '6', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '7', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '8', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, ],}, { text: 'D1853', children: [ { text: '1', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' } ],}, { text: '2', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '3', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '4', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '5', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '6', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '7', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '8', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, ], }, { text: 'K1097', children: [ { text: '1', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' } ],}, { text: '2', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '3', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '4', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '5', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '6', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '7', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '8', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, ], }, { text: 'G1748', children: [ { text: '1', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' } ],}, { text: '2', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '3', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '4', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '5', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '6', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '7', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, { text: '8', children: [ { text: '1' },{ text: '2' },{ text: '3' },{ text: '4' }, { text: '5' },{ text: '6' },{ text: '7' },{ text: '8' },{ text: '9' }, { text: '10' },{ text: '11' },{ text: '12' },{ text: '13' }, { text: '14' },{ text: '15' },{ text: '16' },{ text: '17' } ],}, ], }, ]
    };
},
methods: {
  //点击确认按钮
  toHome() {
    let selectArr = this.$refs.addressRef.getValues()
    let address = {
      trainName: selectArr[0],
      trainNum: selectArr[1],
      seatNum: selectArr[2]
    }
    // 把地址信息保存到本地
    let user = JSON.parse(window.localStorage.getItem('user'))
    user.address = address
    window.localStorage.setItem('user',JSON.stringify(user))
    // 跳转到首页
    this.$router.push('home')
  },
  // 取消
  onCancel() {
    Dialog.alert({
    message: '您必须先填写乘坐信息',
}).then(() => {
});
  }
}
}
</script>
<style lang="less" scoped>
h1 {
      font-size: 20px;
      font-weight: 400;
      display: flex;
      justify-content: center;
      margin-bottom: 40px;
    }
  .van-row {
    text-align: center;
    font-size: 16px;
  }
</style>
